<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="baidu_union_verify" content="541b7be7511ed48192960186f63c4302">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>博客网站</title>
    <link rel="shortcut icon" href="/images/favicon.ico">
    <!-- Bootstrap -->
    <link rel="stylesheet" href="/vendor/bootstrap.min.css">
    
    <!-- <link rel="stylesheet" href="/css/style.css">
    <link rel="stylesheet" href="/css/base.css">
    <link rel="stylesheet" href="/css/summernote.css"> -->
    <link rel="stylesheet" href="/css/all.min.css">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="/vendor/jquery.min.js"></script>
    <script src="/vendor/bootstrap.min.js"></script>

    <!-- <script src="/js/main.js"></script>
    <script src="/js/pagination.js"></script>
    <script src="/js/summernote.js"></script> -->
    <script src="/js/all.min.js"></script>
    <script>
    var _hmt = _hmt || [];
    (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?ebcc7e79498721f482fab9ee7f8068d1";
        var s = document.getElementsByTagName("script")[0]; 
        s.parentNode.insertBefore(hm, s);
    })();
    </script>
    <script>
        $(window).keyup(function(e){
            if (e.keyCode == 13) {
                $('.submit').click()
            }
        })
        function fade(txt){
            $('.message').text(txt)
            $('.message').animate({
                top:0
            })
            setTimeout(function(){
                $('.message').animate({
                    top: '-100%'
                })
            },1500)
        }
        $(function(){
            $('.logout').click(()=>{
                $.ajax({
                    url: "/logout",
                    type: "GET",
                    cache: false,
                    dataType: 'json',
                    success: function (msg) {
                        if (msg) {
                            fade('退出成功')
                            setTimeout(()=>{
                                window.location.href = "/login"
                            },1500)	
                        }
                    },
                    error: function () {
                        console.log('异常');
                    }
                })
            })
        })
    </script>
</head>

<body>
    <div class="message">登录成功</div>
    <a href="#" class="js-fh5co-nav-toggle fh5co-nav-toggle"><i></i></a>
    <aside id="fh5co-aside">
        <nav id="fh5co-main-menu" role="navigation">
            <%  if(session.user){ %>
                <div id="fh5co-logo">
                    <div class="pic"><img src="/images/<%= session.avator %>" alt=""></div>
                    <div class="word">欢迎，<%= session.user %></div>
                </div>
                <ul>
                    <% if(type == 'all'){ %>
                        <li class="fh5co-active"><a href="/posts">全部博客</a></li>
                    <% }else{ %>
                        <li><a href="/posts">全部博客</a></li>
                    <% }%>
                    <% if(type == 'my'){ %>
                        <li class="fh5co-active"><a href="/posts?author=<%= session.user %>">我的博客</a></li>
                    <% }else{ %>
                        <li><a href="/posts?author=<%= session.user %>">我的博客</a></li>
                    <% }%>
                    <% if(type == 'create'){ %>
                        <li class="fh5co-active"><a href="/create">发表博客</a></li>
                    <% }else{ %>
                        <li><a href="/create">发表博客</a></li>
                    <% }%>
                    <li class="logout"><a href="#">退出</a></li>
                </ul>
            <% } %>
            <% if(!session.user){ %>
                <div id="fh5co-logo">
                    <div class="pic"><img src="/images/default-head.png" alt=""></div>
                    <div class="word">欢迎注册登录</div>
                </div>
                <ul>
                    <% if(type == 'all'){ %>
                        <li class="fh5co-active"><a href="/posts">全部博客</a></li>
                    <% }else{ %>
                        <li><a href="/posts">全部博客</a></li>
                    <% }%>
                    <% if(type == 'register'){ %>
                        <li class="fh5co-active"><a href="/register">注册</a></li>
                    <% }else{ %>
                        <li><a href="/register">注册</a></li>
                    <% }%>
                    <% if(type == 'login'){ %>
                        <li class="fh5co-active"><a href="/login">登录</a></li>
                    <% }else{ %>
                        <li><a href="/login">登录</a></li>
                    <% }%>
                </ul>
            <% } %>
        </nav>
        <div class="fh5co-footer">
            <div>Design by 痕迹_Mark</div>
            <div><a href="http://www.miitbeian.gov.cn/" target="_blank">粤ICP备17164280号</a></div>
        </div>
    </aside>
    